package com.example.qxfw.ybzz.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.qxfw.common.entity.zy.TrafficFcst;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.sql.Timestamp;
import java.util.List;

@Mapper
@DS("service")
public interface TrafficFcstMapper extends BaseMapper<TrafficFcst> {

    @Select("SELECT stationid, stationname, longitude, latitude, windd, weather1, ntimes, forecasttype, " +
            "CAST(CAST(case when MaxTemp =-65535 then 0 else MaxTemp end AS float) AS NUMERIC(10, 1)) as MaxTemp, " +
            "CAST(CAST(case when MinTemp =-65535 then 0 else MinTemp end AS float) AS NUMERIC(10, 1)) as MinTemp, " +
            "CAST(CAST(case when WindS =-65535 then 0 else WindS end AS float) AS NUMERIC(10, 1)) as WindS, " +
            "CAST(CAST(case when rain =-65535 then 0 else rain end AS float) AS NUMERIC(10, 1)) as rain " +
            "FROM traffic_fcst " +
            "WHERE datechar = #{dateChar} " +
            "AND timechar = #{timeChar} " +
            "AND forecasttype = #{forecastType}")
    List<TrafficFcst> selectBydateAndTimeAndForecastType(Timestamp dateChar, String timeChar, int forecastType);

}
